package bom.service.impl.organization;

import bom.configuration.constant.SystemStaticConst;
import bom.configuration.util.DictCache;
import bom.dao.organization.DictDao;
import bom.pojo.organization.Dict;
import bom.pojo.query.QueryDict;
import bom.service.i.organization.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @Author: Fancyears·Maylos·Malvis
 * @Description:
 * @Date: Created in  2018/11/27 14:57
 * @Modified By:
 */
@Service
public class DictServiceImpl implements DictService {
    @Autowired(required = false)
    DictDao dictDao;

    @Override
    public List<Dict> query(QueryDict queryDict) {
        return dictDao.query(queryDict);
    }

    @Override
    public Map<String, Object> loadDict() {
        Map<String, Object> result = new HashMap<String, Object>();
        QueryDict queryDict = new QueryDict();
//		queryDict.setIsLoad("1");
        List<Dict> dictList = query(queryDict);
        result.put(SystemStaticConst.RESULT, SystemStaticConst.SUCCESS);
        result.put("data", dictList);
        return result;
    }

    @Override
    public Map<String, Object> reload() {
        Map<String, Object> result = new HashMap<String, Object>();
        List<Dict> dictList = query(null);
        DictCache.reload(dictList);
        result.put(SystemStaticConst.RESULT, SystemStaticConst.SUCCESS);
        result.put(SystemStaticConst.MSG, "重新加载数据字典成功！");
        return result;
    }
}